/*
 * main.c
 *
 *  Created on: 29/gen/2014
 *      Author: Postazione Embedded
 */
//TX mario, RX diana
//canale 7a

#include "stm32f4xx.h"
#include "nrf24l01p/dl.h"

#define LENGTH		20
uint8_t tx_buffer[LENGTH];

void setup();
void loopt();


int main() {
	setup();
	printf("main\n");

	while (1) {
		//loopt();
		toggleLeds(LED[1]);
		RxPacket(tx_buffer);
	}
}

void loopt() {
	TxBroadcast_nRF24L01P(tx_buffer, LENGTH);
	printf("Pacchetto Broadcast!!\n");
	nRF24L01_Delay_us(5000000);
}

void setup(){
	int j = 0;
	init_dl(TX_ADDR);
	RxMode_nRF24L01P();
	for(; j < LENGTH; j++){
		tx_buffer[j+2] = 1;
	}
	tx_buffer[0] = 0;
	tx_buffer[1] = 1;
	tx_buffer[RESERVED_OFFSET] = STARTUP_COMMAND;
	tx_buffer[3] = ENAA_DEFAULT;
	tx_buffer[4] = ENRXADDR_DEFAULT;
	tx_buffer[5] = ADR_WIDTH;
	tx_buffer[6] = RETRY_DEFAULT;
	tx_buffer[7] = 0x0a;
}


